 #include "src/intersect_error/arcs_error.h"


void GenerateTest() {

    int num_tests = 10000;
    double max_error = -1.0;
    double total_error = 0.0;
    int error_count = 0;

    double min = -10.0, max = 10.0;

    for (int i = 0; i < num_tests; i++) {

        double x1 = RandomDouble(min,max);

        double y1 = RandomDouble(min,max);

        double radius1 = RandomDouble(1,6);

        Circle circle1(x1,y1,radius1);

        double theta1 = RandomDouble(0.0,2 * M_PI);
        double theta2 = RandomDouble(0.0,2 * M_PI);

        if(theta1 > theta2){
            std::swap(theta1,theta2);
        }

        Point midpoint = circle1.GetArcMidpoint(theta1,theta2);

        Point p = {RandomDouble(min, max), RandomDouble(min, max)};

        double radius2 = Distance(p,midpoint);

        Circle circle2(p.x,p.y,radius2);

        std::vector<Point> intersections = circle1.CalculateIntersections(circle2);

        if(!intersections.empty()){
            double error = std::numeric_limits<double>::max();

            for(const auto& inter : intersections){
                double d = Distance(midpoint,inter);
                error = std::min(error,d);
            }
            max_error = std::max(max_error,error);
            total_error += error;
            error_count++;
        }




    std::cout << "\nMax error: " << std::scientific << max_error << "\n";
    std::cout << "\nAvgrage Error: " << (error_count > 0 ? total_error / error_count:0.0) << std::endl;
}
}
int main()
{

    GenerateTest();


    return 0;
}
